package com.south.base.proxy.jdk;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author Administrator
 * @date 2019/02/27 10:35
 * @description
 */
@Slf4j
public class DynamicProxyHandler implements InvocationHandler {
    private Object proxied;

    public DynamicProxyHandler(Object proxied) {
        this.proxied = proxied;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        log.info("proxy: {}, method: {}, args: {}", proxy.getClass(), method, Arrays.toString(args));
        return method.invoke(proxied, args);
    }
}
